@import 'option';
@import 'option-group';
@import '../../../styles/var';
@import '../../../styles/mixin';

@select: ~'@{prefix}-select';

.@{select} {
  width: 200px;
  vertical-align: top;
  display: inline-block;
  font-size: 14px;
  line-height: 20px;
  font-family: @font-family;
  background-color: @component-background;
  color: @font-color;

  &:hover,
  &:focus {
    &:not(.is-disabled) {
      .@{select}-toggle {
        border: 1px solid @primary-color;
      }
    }
  }

  &:focus {
    outline: none;

    &:not(.is-disabled) {
      .@{select}-toggle {
        box-shadow: @focus-shadow-primary-light;
      }
    }
  }

  &.is-disabled {
    opacity: 0.5;
    background-color: @component-darker-background;

    .@{select}-toggle {
      cursor: default;
    }

    .@{select}-label {
      background-color: @component-darker-background;
    }
  }

  &.is-open {
    .@{select}-toggle {
      border: 1px solid @primary-color;
      box-shadow: @focus-shadow-primary-light;
      background-color: @component-background;
    }

    .@{select}-arrow {
      &:before {
        transform: rotate(180deg);
      }
    }
  }
}

.@{select}-toggle {
  position: relative;
  cursor: pointer;
  display: block;
  border: 1px solid @border-color;
  min-height: 28px;
  padding-right: 23px;
  transition: border @normal-motion linear, box-shadow @normal-motion linear;
}

.@{select}-text {
  display: block;
  vertical-align: top;
  padding: 4px 10px;
  .ellipsis();
}

.@{select}-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 23px;
  opacity: 0.5;
  .ellipsis();
}

.@{select}-labels {
  padding: 2px 4px;
}

.@{select}-label {
  max-width: calc(100% - 4px);
  box-sizing: border-box;
  background-color: @section-background;
  position: relative;
  display: inline-block;
  vertical-align: top;
  margin: 2px;
  line-height: 20px;
  padding: 0 18px 0 3px;
  .ellipsis();

  &:hover {
    background-color: @primary-background;
  }
}

.@{select}-label-delete {
  position: absolute;
  right: 0;
  top: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: top;
  margin: 2px;
  padding: 2px;
  transition: background @fast-motion linear;

  &:hover:not(.is-disabled) {
    //background-color: @primary-color;
    &:after,
    &:before {
      background-color: @primary-color;
    }
  }

  &:after,
  &:before {
    background-color: @symbol-color;
    display: block;
    content: '';
    position: absolute;
    transform: translate(1.5px, 1.5px) rotate(45deg);
  }

  &:after {
    width: 9px;
    height: 1px;
    margin: 4px 0 0 0;
  }

  &:before {
    width: 1px;
    height: 9px;
    margin: 0 0 0 4px;
  }
}

.@{select}-arrow {
  position: absolute;
  display: block;
  top: 4px;
  box-sizing: border-box;
  bottom: 4px;
  right: 0;
  width: 23px;
  text-align: center;

  &:before {
    position: absolute;
    left: 50%;
    top: 50%;
    vertical-align: top;
    margin: -2px -4px;
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 4px 4px 0 4px;
    border-color: @symbol-color transparent transparent transparent;
    display: inline-block;
  }
}

@supports (transform-style: preserve-3d) {
  .@{select}-arrow {
    &:before {
      transition: transform @normal-motion linear;
    }
  }

  .@{select} {
    &.is-open {
      .@{select}-arrow {
        &:before {
          transform: rotate3d(1, 0, 0, 180deg);
        }
      }
    }
  }
}
